/**
 * @author lk
 * @date 2022/6/2 14:25
 */
package com.mmall.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Optional;

@RestController
public class AdminController {
    @GetMapping("/")
    public String index() {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        Optional<HttpServletRequest> opt = Optional.ofNullable(requestAttributes).
                filter(attr -> attr instanceof ServletRequestAttributes).
                map(attr -> (ServletRequestAttributes) attr).
                map(ServletRequestAttributes::getRequest);
        return "";
    }


}
